package com.quectel.sdk.hikisc.monitor;

import com.quectel.sdk.hikisc.HikClientBuilder;
import com.quectel.sdk.hikisc.constant.HikIscConstants;
import com.quectel.sdk.hikisc.monitor.model.EncodeDeviceDetailResp;
import com.quectel.util.common.JacksonUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author rananxin
 * @email ryan.ran@quectel.com
 * @date 2022/11/4 10:11
 */
public class MonitorTest {

    private static final List<HikIscConstants.EventEnum> EVENT_ENUMS = new ArrayList<>();

    static {
        EVENT_ENUMS.add(HikIscConstants.EventEnum.HIGH_TOSS_ACT);
        EVENT_ENUMS.add(HikIscConstants.EventEnum.REGIONAL_INVASION);
        EVENT_ENUMS.add(HikIscConstants.EventEnum.LICENSE_PLATE_CAPTURE);
        EVENT_ENUMS.add(HikIscConstants.EventEnum.FACE_CAPTURE);
    }

    public static void main(String[] args) {
        MonitorClient monitorClient = HikClientBuilder.builder().ak("20002423").sk("DuCetaDomJRY8kTuoVmY").host("18.118.0.21").build(MonitorClient.class);
//        List<SyncCameraResp> syncCameraResps = monitorClient.drawResources();
//        System.out.println(JacksonUtils.toJsonString(syncCameraResps));
//
//        String[] strings = syncCameraResps.stream().map(o -> o.getCameraIndexCode()).toArray(String[]::new);
//        System.out.println(StringUtils.join(strings, ","));

//        List<String> list = sysadmin.previewDefaultUrl(Arrays.asList("14af48c109d542e088a04856531c128f"));
//        System.out.println(JacksonUtils.toJsonString(list));

        EncodeDeviceDetailResp cameraDeviceDetailResp = monitorClient.encodeDeviceDetail("42d1c5a77c244c4dab6fb87e8a42ef10");
        System.out.println(JacksonUtils.toJsonString(cameraDeviceDetailResp));

//        CameraDeviceDetailResp cameraDeviceDetailResp = monitorClient.encodeDeviceDetail("42d1c5a77c244c4dab6fb87e8a42ef10");
//        System.out.println(JacksonUtils.toJsonString(cameraDeviceDetailResp));

//        HikISCRequester instance = HikISCRequester.getInstance("29147286", "7Dpzb74Z0DKZ7DcOu0dE", "18.118.0.6");
//        String post = instance.post("/api/eventService/v1/eventSubscriptionView", new HashMap<>());
//        System.out.println(post);

//        HikIscRestUtils instance = HikIscRestUtils.getInstance("20002423", "DuCetaDomJRY8kTuoVmY", "18.118.0.21");
//        String post = instance.post("/api/eventService/v1/eventUnSubscriptionByEventTypes", new HashMap<String, Object>(){{
//            put("eventTypes", Arrays.asList(930335,196893,131588,131614,1157632001));
//        }});
//        System.out.println(post);


//        Map<String, List<Integer>> result = new HashMap<>();
//        for (HikIscConstants.EventEnum eventEnum : EVENT_ENUMS) {
//            List<Integer> list = result.get(eventEnum.getCallBackPath());
//            if (CollectionUtils.isEmpty(list)) {
//                list = new ArrayList<>();
//                result.put(eventEnum.getCallBackPath(), list);
//            }
//            list.add(eventEnum.getEventCode());
//        }
//
//        MonitorInstance monitorInstance = HikInstanceBuilder.builder().ak("20002423").sk("DuCetaDomJRY8kTuoVmY").host("18.118.0.21").build(MonitorInstance.class);
//
//        String eventSubUrl =  "http://18.118.0.23/smartcity/dmsapi/hikIscCollect/eventRcv/";
//        result.keySet().forEach(o -> monitorInstance.eventSub(result.get(o).toArray(new Integer[0]), eventSubUrl + o));

//        String hls = monitorClient.playbackUrls("b8f57643411d437fbea661cd09b4c5dd"
//                , "hls", 1, DateUtil.offsetMonth(new Date(), -1), new Date());
//        System.out.println(hls);


    }
}
